package com.mxsoft;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
import org.slf4j.*;

/**
 * Hello world!
 */
public class App {
    private static Logger logger = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) throws InterruptedException {
        logger.info("Hello World");
        if (logger.isDebugEnabled()) {
            logger.debug("this is a debug message");
        }
        logger.error("this is a error message");

//        LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
//        StatusPrinter.print(factory);

        Object[] paramArray = {"newVal", "belowVal", "above"};

        logger.debug("Value {} was inserted between {} and {}.", paramArray);

        Marker notifyAdmin = MarkerFactory.getMarker("NOTIFY_ADMIN");

        logger.error(notifyAdmin, "This is a serious an error requiring the admin's attention", new Exception("Just Testing"));

        for (int i = 0; i < 100; i ++) {
            logger.debug("start debug");
            Thread.sleep(1000);
            logger.error("this is "+i+ " error");
        }

        new Thread(() -> {
            MDC.put("userid", "Alice");
            for (int i = 0; i < 50; i ++) {
                logger.debug("Alice says hello");
            }
        }).start();

        new Thread(() -> {
            MDC.put("userid", "Alex");
            for (int i = 0; i < 50; i ++) {
                logger.debug("Alex says hello");
            }
        }).start();


    }
}
